package com.test5;

import java.io.FileInputStream;

/**
 * 文件字节输入流
 */
public class FileInputStreamTest {
    public static void main(String[] args) throws Exception {
        //创建FileInputStream，并指定文件路径
        FileInputStream fis = new FileInputStream("C:\\Users\\LDH\\Desktop\\test.txt");
        //读取文件(单个字节读取)
//        int data = 0;
//        while ((data = fis.read()) != -1){
//            System.out.println((char) data);
//        }
        //读取文件(多个字节)
        byte[] buf = new byte[6];
        int count = 0;
        while ((count =fis.read(buf)) != -1){
            System.out.println(new String(buf,0,count));
        }

        //关闭
        fis.close();
        System.out.println("关闭");
    }
}
